<?php

class Db_Tables2_BSku961Rules
{
	function __construct() {
		$this->dealers_db = Zend_Registry::get("dealers_db");
	}
	
	function GetDiscountValue($value = 0)
	{
		$result = 0;
		
		$select = $this->dealers_db->select();
		$select->from("b_sku_961_rules", "*");
		$rows = $this->dealers_db->fetchAll($select);

		if(!empty($rows))
		{
			foreach($rows as $row)
			{
				if($value >= $row['min_value'] && $value < $row['max_value'])
				{
					$result = $value * $row['ratio'];
					break;
				}
			}
		}
		
		return $result;
	}
}